package com.hao.staservice.controller;


import com.hao.commonutils.R;
import com.hao.staservice.service.StatisticsDailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author hao
 * @since 2021-01-27
 */
@RestController
@CrossOrigin
@RequestMapping("/staservice/sta")
public class StatisticsDailyController {

    @Autowired
    private StatisticsDailyService staService;

    @PostMapping("countRegister/{day}")
    public R countRegister(@PathVariable String day){
        staService.registerCount(day);
        return R.ok();
    }

    /**
     * 展示统计数据
     *
     * @param type     类型
     * @param beginDay 开始一天
     * @param endDay   结束一天
     * @return {@link R}
     */
    @GetMapping("showData/{type}/{beginDay}/{endDay}")
    public R showData(@PathVariable String type,@PathVariable String beginDay,
                      @PathVariable String endDay){
        Map<String,Object> map = staService.showData(type,beginDay,endDay);
        return R.ok().data(map);
    }

}

